home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / fragrouter / Libnet-0.99b / aclocal.m4 < prev    next >
Encoding:
M4 Source File  |  1999-07-26  |  7.1 KB  |  281 lines

  1. dnl aclocal.m4 generated automatically by aclocal 1.4
  2.  
  3. dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
  4. dnl This file is free software; the Free Software Foundation
  5. dnl gives unlimited permission to copy and/or distribute it,
  6. dnl with or without modifications, as long as this notice is preserved.
  7.  
  8. dnl This program is distributed in the hope that it will be useful,
  9. dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  10. dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11. dnl PARTICULAR PURPOSE.
  12.  
  13. dnl $Id: aclocal.m4,v 1.1.1.1 1999/05/18 15:33:41 dugsong Exp $
  14. dnl
  15. dnl     Libnet specific autoconf macros
  16. dnl     Copyright (c) 1998, 1999 Mike D. Schiffman <mike@infonexus.com>
  17. dnl                              route|daemon9 <route@infonexus.com>
  18. dnl     All rights reserved.
  19. dnl
  20.  
  21. dnl
  22. dnl Checks to see if this linux kernel has a working PF_PACKET
  23. dnl
  24. dnl usage:
  25. dnl
  26. dnl     AC_LIBNET_CHECK_PF_PACKET
  27. dnl
  28. dnl results:
  29. dnl
  30. dnl     HAVE_PF_PACKET (DEFINED)
  31. dnl
  32.  
  33. AC_DEFUN(AC_LIBNET_CHECK_PF_PACKET,
  34. [
  35.     AC_MSG_CHECKING(for PF_PACKET)
  36.     AC_CACHE_VAL(ac_libnet_have_pf_packet,
  37.  
  38.         [case "$target_os" in
  39.  
  40.         linux)
  41.                 ac_libnet_have_pf_packet = no
  42.                 ;;
  43.         *)
  44.  
  45.     cat > pf_packet-test.c << EOF
  46. #include <net/if.h>
  47. #if (__GLIBC__)
  48. #include <netinet/if_ether.h>
  49. #include <net/if_arp.h>
  50. #else
  51. #include <linux/if_arp.h>
  52. #include <linux/if_ether.h>
  53. #endif
  54. #if (PF_PACKET)
  55. #ifndef SOL_PACKET
  56. #define SOL_PACKET 263
  57. #endif  /* SOL_PACKET */
  58. #include <linux/if_packet.h>
  59. #endif
  60. #include "./include/libnet.h"
  61.  
  62. int
  63. main()
  64. {
  65. #if (PF_PACKET)
  66.     int fd;
  67.     struct sockaddr_ll sa;
  68.     struct ifreq ifr;
  69.     struct packet_mreq mr;
  70.     char *device ="lo";
  71.  
  72.     fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  73.     if (fd == -1)
  74.     {
  75.         printf("choked");
  76.         exit (EXIT_FAILURE);
  77.     }
  78.  
  79.     memset(&sa, 0, sizeof(sa));
  80.     strcpy(ifr.ifr_name, device);
  81.     if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)
  82.     {
  83.         printf("choked");
  84.         exit (EXIT_FAILURE);
  85.     }
  86.     sa.sll_family = AF_PACKET;
  87.     sa.sll_ifindex = ifr.ifr_ifindex;
  88.     sa.sll_protocol = htons(ETH_P_ALL);
  89.  
  90.     memset(&mr, 0, sizeof (mr));
  91.     mr.mr_ifindex = sa.sll_ifindex;
  92.     mr.mr_type = PACKET_MR_ALLMULTI;
  93.  
  94.     if (setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, (char *)&mr,
  95.             sizeof (mr)) < 0)
  96.     {
  97.         printf("choked\n");
  98.         exit (EXIT_FAILURE);
  99.     }
  100.     /* yay.  we made it and it workz! */
  101.     printf("yes");
  102. #else   /* PF_PACKET */
  103.     printf("no");
  104. #endif
  105.     exit (EXIT_SUCCESS);
  106. }
  107. EOF
  108.     ${CC-cc} -o pf_packet-test $CFLAGS pf_packet-test.c >/dev/null 2>&1
  109.  
  110.     # Oopz 4.3 BSD doesn't have this.  Sorry.
  111.     if test ! -x ./pf_packet-test ; then
  112.         ac_libnet_have_pf_packet=choked
  113.     else
  114.         ac_libnet_have_pf_packet=`./pf_packet-test`;
  115.     fi
  116.  
  117.     if test $ac_libnet_have_pf_packet = choked; then
  118.         AC_MSG_RESULT(test program choked... assuming no)
  119.     elif test $ac_libnet_have_pf_packet = yes; then
  120.         AC_DEFINE(HAVE_PF_PACKET)
  121.     fi
  122.  
  123.     if test $ac_libnet_have_pf_packet != choked; then
  124.         AC_MSG_RESULT($ac_libnet_have_pf_packet)
  125.     fi
  126.     rm -f pf_packet-test* core core.pf_packet-test
  127.     ;;
  128.     esac])
  129.  
  130. ])
  131.  
  132.  
  133. dnl
  134. dnl Looks for a previous libnet version and attempts to determine which verion
  135. dnl it is.  Version 0.8 was the first version that actually knew internally
  136. dnl what version it was.
  137. dnl
  138. dnl usage:
  139. dnl
  140. dnl     AC_LIBNET_CHECK_LIBNET_VERSION
  141. dnl
  142. dnl results:
  143. dnl
  144. dnl
  145. dnl
  146.  
  147. AC_DEFUN(AC_LIBNET_CHECK_LIBNET_VER,
  148. [
  149.     AC_CHECK_LIB(net, build_ip, AC_MSG_CHECKING(version) \
  150.  
  151.     if ! test -f $LIB_PREFIX/libnet.a; then
  152.         AC_MSG_RESULT($LIB_PREFIX/libnet.a doesn't exist)
  153.         AC_MSG_RESULT(previous libnet install lives elsewhere, you should probably find it)
  154.     else
  155.         __LIBNET_VERSION=`strings $LIB_PREFIX/libnet.a | grep "libnet version"\
  156.                 | cut -f3 -d" "`;\
  157.         if test -z "$__LIBNET_VERSION"; then
  158.             AC_MSG_RESULT(<0.8)
  159.         else
  160.             AC_MSG_RESULT($__LIBNET_VERSION)
  161.         fi
  162.     fi\
  163.     )
  164. ])
  165.  
  166.  
  167. dnl
  168. dnl Checks to see if this linux kernel uses ip_sum or ip_csum
  169. dnl (Pulled from queso)
  170. dnl
  171. dnl usage:
  172. dnl
  173. dnl     AC_LIBNET_CHECK_IP_CSUM
  174. dnl
  175. dnl results:
  176. dnl
  177. dnl     HAVE_STRUCT_IP_CSUM (DEFINED)
  178. dnl
  179.  
  180. AC_DEFUN(AC_LIBNET_CHECK_IP_CSUM,
  181. [
  182.     AC_MSG_CHECKING([struct ip contains ip_csum])
  183.     AC_TRY_COMPILE([
  184.         #define __BSD_SOURCE
  185.         #define _BSD_SOURCE
  186.         #include <sys/types.h>
  187.         #include <netinet/in.h>
  188.         #include <netinet/in_systm.h>
  189.         #include <netinet/ip.h>],
  190.         [
  191.             struct ip ip;
  192.             ip.ip_csum = 0;
  193.         ],
  194.         [AC_MSG_RESULT(yes);
  195.         AC_DEFINE(HAVE_STRUCT_IP_CSUM)],
  196.         [AC_MSG_RESULT(no);
  197.     ])
  198. ])
  199.  
  200. dnl
  201. dnl Checks to see if unaligned memory accesses fail
  202. dnl (Pulled from libpcap)
  203. dnl
  204. dnl usage:
  205. dnl
  206. dnl     AC_LBL_UNALIGNED_ACCESS
  207. dnl
  208. dnl results:
  209. dnl
  210. dnl     LBL_ALIGN (DEFINED)
  211. dnl
  212.  
  213. AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
  214.     [AC_MSG_CHECKING(if unaligned accesses fail)
  215.     AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
  216.         [case "$target_cpu" in
  217.  
  218.         alpha|hp*|mips|sparc)
  219.                 ac_cv_lbl_unaligned_fail=yes
  220.                 ;;
  221.  
  222.         *)
  223.                 cat >conftest.c <<EOF
  224. #                   include <sys/types.h>
  225. #                   include <sys/wait.h>
  226. #                   include <stdio.h>
  227.                     unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  228.                     main()
  229.                     {
  230.                         unsigned int i;
  231.                         pid_t pid;
  232.                         int status;
  233.                         /* avoid "core dumped" message */
  234.                         pid = fork();
  235.                         if (pid <  0)
  236.                         {
  237.                             exit(2);
  238.                         }
  239.                         if (pid > 0)
  240.                         {
  241.                             /* parent */
  242.                             pid = waitpid(pid, &status, 0);
  243.                             if (pid < 0)
  244.                             {
  245.                                 exit(3);
  246.                             }
  247.                             exit(!WIFEXITED(status));
  248.                         }
  249.                         /* child */
  250.                         i = *(unsigned int *)&a[[1]];
  251.                         printf("%d\n", i);
  252.                         exit(0);
  253.                     }
  254. EOF
  255.                 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  256.                     conftest.c $LIBS > /dev/null 2>&1
  257.                 # Oopz 4.3 BSD doesn't have this.  Sorry.
  258.                 if test ! -x conftest ; then
  259.                         dnl failed to compile for some reason
  260.                         ac_cv_lbl_unaligned_fail=yes
  261.                 else
  262.                         ./conftest > conftest.out
  263.                         if test ! -s conftest.out ; then
  264.                                 ac_cv_lbl_unaligned_fail=yes
  265.                         else
  266.                                 ac_cv_lbl_unaligned_fail=no
  267.                         fi
  268.                 fi
  269.                 rm -f conftest* core core.conftest
  270.                 ;;
  271.         esac])
  272.     AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
  273.     if test $ac_cv_lbl_unaligned_fail = yes ; then
  274.             AC_DEFINE(LBL_ALIGN)
  275.     fi
  276. ])
  277.  
  278.  
  279. dnl EOF
  280.  
  281.